/*
@Author: chenhuocan
@Date: 2020-03-10 16:58:33
 * @LastEditors: amberself
 * @LastEditTime: 2021-01-08 14:03:55
@Description: 基础网络请求类
*/
import axios from 'axios'
import store from '@/store'

const axiosHeader = {
  withCredentials: true, // send cookies when cross-domain requests
  // timeout: 30000, /* 请求时间*/
  method: 'post'
}

const pending = []
const CancelToken = axios.CancelToken

/* 创建 axios 实例。*/
const service = axios.create(axiosHeader)

/* 请求拦截器*/
service.interceptors.request.use((config) => {
  config.cancelToken = new CancelToken((c) => {
    pending.push({ u: config.url, f: c })
  })
  return config
},
error => {
  // d对请求错误执行某些操作。
  return Promise.reject(error)
})

export default service

